package com.example.demo.framework.util;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

public class JodaUtil {

	public static final String DATETIME_FORMAT_01 = "yyyy-MM-dd HH:mm:ss";
	public static final String DATETIME_FORMAT_02 = "MMddyymmssHH";
	public static final String DATETIME_FORMAT_03 = "yyyyMMddHHmmss";

	public static String now() {
		return new DateTime().toString(DATETIME_FORMAT_01);
	}

	public static String now(String format) {
		return new DateTime().toString(format);
	}

	/**
	 * token是否过期 (过期时间2h)
	 * 
	 * @param tokenTime
	 * @return
	 */
	public static boolean tokenIsOverdue(String tokenTime) {
		return DateTimeFormat.forPattern(DATETIME_FORMAT_01).parseDateTime(tokenTime).plusHours(2).isBeforeNow();
	}

}
